package com.fs.controller;

import com.fs.pojo.SysPost;
import com.fs.pojo.User;
import com.fs.service.SysPostService;
import com.fs.service.UserService;
import com.fs.vo.Condition;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService service;

    @Resource
    private SysPostService sysPostService;

//    @Resource
//    private SysDeptService sysDeptService;

    /**
     * 分页条件查询所有人员职位部门
     *
     * @param condition
     * @return
     */
    @PostMapping("/all")
    public PageInfo<User> selectAll(@RequestBody Condition<User> condition) {
        return service.selectAll(condition);
    }

    /**
     * 根据id删除人员部门职位表
     *
     * @param userId
     */
    @DeleteMapping("/deleteById/{userId}")
    public void deleteById(@PathVariable int userId) {
        service.deleteById(userId);
    }

    /**
     * 修改人员信息
     *
     * @param user
     */
    @PostMapping("/updata")
    public void updata(@RequestBody User user) {
        System.out.println("=========================================================================================");
        System.out.println(user);
    }

    /**
     * 查询人员职位表
     */
    @GetMapping("/selectPost")
    public List<SysPost> selectPost() {
        return sysPostService.select();
    }

    /**
     * 查询人员部门表
     */
//    @GetMapping("/selectDept")
//    public List<Sysdepts> selectDept() {
//        return sysDeptService.selectAll();
//    }
}
